﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Platformer
{
    public class Jetpack
    {
        PlatformerGame game;
        Smoke smoke;

        /// <summary>
        /// Is the player using the jetpack right now ?
        /// </summary>
        public bool IsUsed
        {
            get { return isUsed; }
            set { isUsed = value; }
        }
        bool isUsed = false;

        /// <summary>
        /// When the power reaches 0, the jetpack is no more usable.
        /// </summary>
        public int Power
        {
            get { return power; }
            set { power = value; }
        }
        int power = 100;

        /// <summary>
        /// When the jetpack isn't used for a period of time, its power starts to regenerate.
        /// </summary>
        public bool Regenerating
        {
            get { return regenerating; }
            set { regenerating = value; }
        }
        bool regenerating = false;

        /// <summary>
        /// This device allows the player to fly for a short period of time.
        /// </summary>
        /// <param name="game"></param>
        public Jetpack(PlatformerGame game)
        {
            smoke = new Smoke(game, Vector2.Zero);
        }

        public void Update()
        {
            if (Keyboard.GetState().IsKeyDown(Character.keyJetpack))
            {
                TurnOn();
            }
            smoke.Update();
        }

        public void Draw(SpriteBatch spriteBatch)
        {
            smoke.Draw(spriteBatch);
        }

        /* Custom */
        void TurnOn()
        {
            isUsed = true;
            smoke.Active = true;
        }

        void TurnOff()
        {
            isUsed = false;
            smoke.Active = false;
        }
    }
}
